package io.renren.modules.weldingcurrent.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.weldingcurrent.entity.WeldingmachineCurrentEntity;
import io.renren.modules.weldingcurrent.service.WeldingmachineCurrentService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
@RestController
@RequestMapping("weldingcurrent/weldingmachinecurrent")
public class WeldingmachineCurrentController {
    @Autowired
    private WeldingmachineCurrentService weldingmachineCurrentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("weldingcurrent:weldingmachinecurrent:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = weldingmachineCurrentService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{no}")
    @RequiresPermissions("weldingcurrent:weldingmachinecurrent:info")
    public R info(@PathVariable("no") Integer no){
		WeldingmachineCurrentEntity weldingmachineCurrent = weldingmachineCurrentService.getById(no);

        return R.ok().put("weldingmachineCurrent", weldingmachineCurrent);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("weldingcurrent:weldingmachinecurrent:save")
    public R save(@RequestBody WeldingmachineCurrentEntity weldingmachineCurrent){
		weldingmachineCurrentService.save(weldingmachineCurrent);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("weldingcurrent:weldingmachinecurrent:update")
    public R update(@RequestBody WeldingmachineCurrentEntity weldingmachineCurrent){
		weldingmachineCurrentService.updateById(weldingmachineCurrent);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("weldingcurrent:weldingmachinecurrent:delete")
    public R delete(@RequestBody Integer[] nos){
		weldingmachineCurrentService.removeByIds(Arrays.asList(nos));

        return R.ok();
    }

}
